using UnityEngine;

public class AspectRatioScaler : MonoBehaviour
{
	public float scaleAtDefaultScreenRatio;

	public float scaleAtThinScreenRatio;

	public float scaleAtThickScreenRatio;

	private float defaultScreenRatio = 0.5625f;

	private float thinScreenRatio = 0.5f;

	private float thickScreenRatio = 0.75f;

	private void Awake()
	{
		SetTransformScale();
	}

	private void SetTransformScale()
	{
		float aspect = Camera.main.aspect;
		Vector3 localScale = default(Vector3);
		if (aspect < defaultScreenRatio)
		{
			float num = defaultScreenRatio - thinScreenRatio;
			float num2 = scaleAtDefaultScreenRatio - scaleAtThinScreenRatio;
			float num3 = defaultScreenRatio - aspect;
			float num4 = scaleAtDefaultScreenRatio - num3 / num * num2;
			localScale.Set(num4, num4, num4);
			base.transform.localScale = localScale;
		}
		else if (aspect > defaultScreenRatio && aspect <= thickScreenRatio)
		{
			float num5 = thickScreenRatio - defaultScreenRatio;
			float num6 = scaleAtThickScreenRatio - scaleAtDefaultScreenRatio;
			float num7 = aspect - defaultScreenRatio;
			float num8 = scaleAtDefaultScreenRatio + num7 / num5 * num6;
			localScale.Set(num8, num8, num8);
			base.transform.localScale = localScale;
		}
		else
		{
			localScale.Set(scaleAtDefaultScreenRatio, scaleAtDefaultScreenRatio, scaleAtDefaultScreenRatio);
			base.transform.localScale = localScale;
		}
	}
}
